package com.gz.logistics.library.pojo;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 杜志娟 on 2016/4/22.
 */
public class GiveClothes {

    private String orderno; //订单编号
    private String status;//订单状态
    private String address;//用户地址
    private String phone;//联系方式
    private String clothgategoryid;
    private int clothnum;//衣服数量
    private String greservetime;

    public String getOrderno() {
        return orderno;
    }

    public void setOrderno(String orderno) {
        this.orderno = orderno;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getClothgategoryid() {
        return clothgategoryid;
    }

    public void setClothgategoryid(String clothgategoryid) {
        this.clothgategoryid = clothgategoryid;
    }

    public int getClothnum() {
        return clothnum;
    }

    public void setClothnum(int clothnum) {
        this.clothnum = clothnum;
    }

    public String getGreservetime() {
        return greservetime;
    }

    public void setGreservetime(String greservetime) {
        this.greservetime = greservetime;
    }

    public String getSreservetime() {
        return sreservetime;
    }

    public void setSreservetime(String sreservetime) {
        this.sreservetime = sreservetime;
    }

    private String sreservetime;

    public static List<GiveClothes> parse(JSONArray jsonArray) throws JSONException {
        if (jsonArray == null || jsonArray.length() <= 0){
            return null;
        }
        List<GiveClothes> getClothesList = new ArrayList<GiveClothes>();
        for (int i = 0 ; i < jsonArray.length() ; i++ ){
            GiveClothes giveclothes = new GiveClothes();
            JSONObject object = jsonArray.getJSONObject(i);
            giveclothes.orderno = object.getString("order_no");
            giveclothes.status = object.getString("status");
            giveclothes.address = object.getString("address");
            giveclothes.phone = object.getString("phone");
            giveclothes.clothgategoryid = object.getString("cloth_gategory_id");
            giveclothes.clothnum = object.getInt("cloth_num");
            giveclothes.greservetime = object.getString("g_reserve_time");
            giveclothes.sreservetime = object.getString("s_reserve_time");
            getClothesList.add(giveclothes);
        }
        return getClothesList;
    }

    public static GiveClothes parse(JSONObject object) throws JSONException {
        if (object == null){
            return null;
        }
        GiveClothes giveclothes = new GiveClothes();
        giveclothes.orderno = object.getString("order_no");
        giveclothes.status = object.getString("status");
        giveclothes.address = object.getString("address");
        giveclothes.phone = object.getString("phone");
        giveclothes.clothgategoryid = object.getString("cloth_gategory_id");
        giveclothes.clothnum = object.getInt("cloth_num");
        giveclothes.greservetime = object.getString("g_reserve_time");
        giveclothes.sreservetime = object.getString("s_reserve_time");
        return giveclothes;

    }

}
